<template>
  <a-card title="审批记录">
    <a-table
      ref="table"
      size="middle"
      :scroll="{ x: true }"
      bordered
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="false"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange"
    >
      <span slot="operateResult" slot-scope="text, record">
        <a-tag :color="text == 1 ? 'green' : 'volcano'">
          {{ text == 1 ? '通过' : '' }}
          {{ text == 2 ? '驳回' : '' }}
        </a-tag>
      </span>
    </a-table>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import { getAction } from '@/api/manage'
export default {
  name: 'ExOperationRecordIndex',
  mixins: [JeecgListMixin, mixinDevice],
  components: {},
  props: {
    module: {
      type: String,
      default: '',
    },
    entryId: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      description: '审批记录',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        // {
        //   title: '模块',
        //   align: 'center',
        //   dataIndex: 'moduleText',
        // },
        {
          title: '操作人',
          align: 'center',
          dataIndex: 'operator',
        },
        {
          title: '操作时间',
          dataIndex: 'operateTime',
          align: 'center',
        },
        {
          title: '操作结果',
          dataIndex: 'operateResult',
          align: 'center',
          scopedSlots: { customRender: 'operateResult' },
        },
        {
          title: '操作意见',
          dataIndex: 'operateOpinion',
          align: 'center',
        },
      ],
      url: {
        list: '/exOperationRecord/exOperationRecord/list',
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: {
        id: '',
        module: '',
      },
      loading: false,
    }
  },
  watch: {
    entryId(newVal, oval) {
      this.queryParam.entryId = newVal
      this.loadData(1)
    },
  },
  created() {
    this.queryParam.entryId = this.entryId
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  methods: {
    initDictConfig() {},
    loadData(arg) {
      if (this.queryParam.entryId == '' || this.queryParam.entryId == undefined) {
        return
      }
      this.queryParam.module = this.module
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams() //查询条件
      this.loading = true
      getAction(this.url.list, params)
        .then((res) => {
          if (res.success) {
            //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
            this.dataSource = res.result.records || res.result
            if (res.result.total) {
              this.ipagination.total = res.result.total
            } else {
              this.ipagination.total = 0
            }
            //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.loading = false
        })
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>